﻿namespace MicroCloud.Extensions
{
    /// <summary>
    /// 服务集合接口辅助扩展方法类
    /// </summary>
    public static partial class IServiceCollectionExtensions
    {
        /// <summary>
        /// 获取 <see cref="IConfiguration"/> 配置信息
        /// </summary>
        /// <param name="services">服务集合</param>
        /// <returns></returns>
        public static IConfiguration GetConfiguration(this IServiceCollection services)
        {
            return services.GetSingletonOrDefault<IConfiguration>();
        }

        /// <summary>
        /// 获取 <see cref="MicroCloudOptions"/> 配置信息
        /// </summary>
        /// <param name="services">服务集合</param>
        /// <returns></returns>
        public static MicroCloudOptions GetMicroCloudOptions(this IServiceCollection services)
        {
            IConfiguration configuration = services.GetConfiguration();
            return configuration.GetMicroCloudOptions();
        }


    }
}